<form id="add-form" class="form-horizontal" role="form" data-toggle="validator" method="POST" action="" style="background-color: #fff;padding-top: 20px;">
    <input type="hidden" name="row[rid]" value="{$row.id}">
    <div class="form-group">
        <label class="control-label col-xs-12 col-sm-2">{:__('类型')}:</label>
        <div class="col-xs-12 col-sm-8">
            <select class="form-control" name="row[type]">
                <?php if($type == 10){?>
                <option value="10">渠道催办</option>
                <?php }?>
                <?php if($type == 11){?>
                <option value="11">舆情处理</option>
                <?php }?>
            </select>
        </div>
    </div>
    <div class="form-group">
        <label class="control-label col-xs-12 col-sm-2">{:__('内容')}:</label>
        <div class="col-xs-12 col-sm-8">
            <textarea id="c-cuiban_beizhu" class="form-control" name="row[cuiban_beizhu]" type="text"></textarea>
        </div>
    </div>
    <div class="form-group">
        <label for="c-cuiban_img" class="control-label col-xs-12 col-sm-2">{:__('图片')}:</label>
        <div class="col-xs-12 col-sm-8">
            <div class="input-group">
                <input id="c-cuiban_img" class="form-control" size="50" name="row[cuiban_img]" type="text"
                       value="">
                <div class="input-group-addon no-border no-padding">
                    <span><button type="button" id="faupload-cuiban_img" class="btn btn-danger faupload"
                                  data-input-id="c-cuiban_img"
                                  data-mimetype="image/gif,image/jpeg,image/png,image/jpg,image/bmp,image/webp"
                                  data-multiple="true" data-preview-id="p-cuiban_img"><i class="fa fa-upload"></i> {:__('Upload')}</button></span>
                    <span><button type="button" id="fachoose-cuiban_img" class="btn btn-primary fachoose"
                                  data-input-id="c-cuiban_img" data-mimetype="image/*" data-multiple="true"><i
                            class="fa fa-list"></i> {:__('Choose')}</button></span>
                </div>
                <span class="msg-box n-right" for="c-cuiban_img"></span>
            </div>
            <ul class="row list-inline faupload-preview" id="p-cuiban_img"></ul>
        </div>
    </div>
    <div class="form-group">
        <label class="control-label col-xs-12 col-sm-2">{:__('查勘人')}:</label>
        <div class="col-xs-12 col-sm-8">
            <select name="row[fenpei]" id="c-fenpei"  class="form-control">
                <option value="">请选择查勘人</option>
                {volist name="fenpei" id="vo"}
                <option value="{$vo.id}">{$vo.username}</option>
                {/volist}
            </select>
        </div>
    </div>


    <div class="form-group" style="margin-top: 50px;padding-bottom: 50px;margin-left: 150px;">
        <label class="control-label col-xs-12 col-sm-2"></label>
        <div class="col-xs-12 " style="margin: auto;">
            <button type="button" class="btn btn-primary btn-embossed " style="margin-left: 10px;" onclick="zuihou_save()">{:__('保存并关闭')}</button>
        </div>
    </div>
</form>

<script src="/assets/libs/jquery/dist/jquery.js"></script>
<script>
    function zuihou_save() {
        var formData = $("#add-form").serialize();
        $.ajax({
            url: "{:url('baoan/beizhu/save_list')}",
            data: formData,
            type: 'post',
            dataType: 'json',
            success: function (ret) {
                if (ret.code == 1) {
                    var res = ret.data
                    var html1 = '';
                    var i = 0;
                    for (i = 0;i<res.cuiban_img.length;i++){
                        html1 += `<img src="`+res.cuiban_img[i]+`"  data-magnify="gallery" data-src="`+res.cuiban_img[i]+`" style="max-width: 100px;">`;
                    }
                    var html2 = '';
                    if(res.is_ben == 1){
                        html2 = `<input class="save" type="button"  value="回复"
                               style="width:50px!important;height:30px;border: none;background:#3683D3 !important;color: #fff;">`;
                    }
                    var html = `<tr class="form-inline">
                                <td class="idd" style="display: none"><input type="hidden" name="row[id]" value="`+res.id+`"></td>
                                <td class="tt">`+res.date+`</td>
                                <td class="name">`+res.user_name+`</td>
                                <td class="type">`+res.type+`</td>
                                <td></td>
                                <td></td>
                                <td></td>
                                <td></td>
                                <td class="content"></td>
                                <td>`+res.fenpei+`</td>
                                <td id="buchang_date_`+res.buchangdate+`"></td>
                                <td id="buchang_beizhu_`+res.id+`" class="content"></td>
                                <td id="buchang_img_`+res.id+`"> </td>
                                <td id="cuiban_beizhu_`+res.id+`" class="content">`+res.cuiban_beizhu+`</td>
                                <td id="cuiban_img_`+res.id+`"> `+html1+`</td>
                                <td class="caozuo">`+html2+`</td>
                            </tr>`;
                    $('#first-table1', window.parent.document).append(html);
                    layer.msg('保存成功！', {
                        time: 1000,
                        icon: 1
                    }, function (index) {
                        var index = parent.layer.getFrameIndex(window.name); //先得到当前iframe层的索引
                        parent.layer.close(index); //执行关闭
                    })
                } else {
                    layer.alert(res.msg)
                }
            }
        })
    }
    $("#c-ld_type").on("click", function() {
        var name = $('#c-name1').val();
        $('#c-name').val(name)
    })
    $("#c-ld_type1").on("click", function() {
        $('#c-name').val('')
    })
</script>